package com.springboot.controller;

import com.springboot.entity.PeopleEntity;
import com.springboot.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author WinterSun
 * @date 2020/9/26 - 14:54
 */
@RestController
public class TestController {

    @Autowired
    private TestService testService;

    @GetMapping("/findId")
    public PeopleEntity findPerson(@RequestParam("id") Long id){
        return testService.selectByPrimaryKey(id);
    }

    @PostMapping("/insert")
    public String selectPerson(@RequestBody PeopleEntity peopleEntity){
        try {
            return "成功插入：" + testService.InsertMethod(peopleEntity) + "条";
        } catch (Exception e) {
            e.printStackTrace();
            return "插入失败！";
        }
    }

}
